package com.lesso.lpq.sunflower.domain.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.lesso.lpq.sunflower.domain.repository.EmployeeDeviceRepository;
import com.lesso.lpq.sunflower.infra.assembler.EmployeeDeviceAssembler;
import com.lesso.lpq.sunflower.model.EmployeeDevice;
import com.lesso.lpq.sunflower.pojo.dto.EmployeeDeviceDTO;
import com.lesso.lpq.sunflower.pojo.dto.EmployeeDeviceQueryDTO;
import com.lesso.lpq.sunflower.pojo.vo.EmployeeDeviceVO;
import org.springframework.stereotype.Service;

/**
 * @ClassName : EmployeeDeviceDomainService
 * @Description :
 * @Author : 罗培棋
 * @Date: 2025-07-05 17:13
 */
@Service
public class EmployeeDeviceDomainService {
    private final EmployeeDeviceRepository employeeDeviceRepository;

    public EmployeeDeviceDomainService(EmployeeDeviceRepository employeeDeviceRepository) {
        this.employeeDeviceRepository = employeeDeviceRepository;
    }

    public Long save(EmployeeDeviceDTO dto) {
        EmployeeDevice employeeDevice = EmployeeDeviceAssembler.INSTANCE.dtoToEntity(dto);
        return employeeDeviceRepository.save(employeeDevice);
    }

    public Page<EmployeeDeviceVO> page(EmployeeDeviceQueryDTO dto) {
        return employeeDeviceRepository.getPageList(dto);
    }

    public Page<EmployeeDeviceVO> customPage(EmployeeDeviceQueryDTO dto) {
        return employeeDeviceRepository.getCustomPageList(dto);
    }

    public void deleteById(Long id) {
        employeeDeviceRepository.removeById(id);
    }

    public void update(EmployeeDeviceDTO dto) {
        employeeDeviceRepository.updateById(dto);
    }

    public EmployeeDeviceVO getByEmployeeId(String employeeId) {
        return employeeDeviceRepository.getByEmployeeId(employeeId);
    }
}
